home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 386 / insttest / leamovea.s < prev    next >
Text File  |  1985-11-19  |  3KB  |  90 lines

  1.  ; Program Name: LEAMOVEA.S
  2.  ;      Version: 1.001
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    Assemble with ASSEMPRO and save with a TOS extension.
  7.  
  8.  ; Execution Instructions:
  9.  
  10.  ;     Execute from the desktop; or execute SPAWN.TTP, type LEAMOVEA.TOS on
  11.  ; its command line and view this program's output in LEAMOVEA.DAT.
  12.  
  13.  ; Program Function:
  14.  
  15.  ;    Confirms (or refutes) the statement on page 113 of the Stan Kelly-
  16.  ; Bootle book, to wit: MOVEA.Z #<label>, A0 is equivalent to LEA, and
  17.  ; faster.
  18.  
  19.  ;    For each of the two methods of loading the address of a string into
  20.  ; and address register, calculates the memory occupied by each method, and
  21.  ; calculates the execution time in milliseconds required for 50,000
  22.  ; executions of each.
  23.  
  24.  ; PROGRAM RESULTS:
  25.  
  26.  ;      When the program containing the two instructions under discussion
  27.  ; is assembled in AssemPro's Relocatable mode, the instructions are
  28.  ; equivalent in speed and requisite memory.
  29.  
  30.  ;      However, when the program is assembled in AssemPro's PC-relative
  31.  ; mode, the LEA instruction is faster and requires less memory.  The claim
  32.  ; that the MOVEA.Z instruction is faster than the LEA instruction is,
  33.  ; therefore, soundly refuted.
  34.  
  35.  ;      But, when the program is assembled in PC-relative mode, the MOVEA.Z
  36.  ; instruction does not move the correct value into the address register,
  37.  ; so there is really no choice when either pc-relative addressing or
  38.  ; PC-relative assembly is used--LEA must be used then.
  39.  
  40. calculate_program_size:
  41.  lea        -$102(pc), a1       ; Fetch basepage start address.
  42.  lea        program_end, a0     ; Fetch program end = array address.
  43.  trap       #6                  ; Return unused memory to op system.
  44.  lea        stack, a7
  45.  
  46. initialize_registers_1:
  47.  lea        header_1, a0       
  48.  lea        header_2, a1
  49.  lea        lea_start, a3
  50.  lea        lea_end, a4
  51.  lea        heading, a5
  52.  move.w     #50000, d7
  53.  trap       #9
  54.  
  55. initialize_registers_2:
  56.  lea        header_3, a0       
  57.  lea        header_4, a1
  58.  lea        movea_start, a3
  59.  lea        movea_end, a4
  60.  lea        heading, a5
  61.  move.b     #0, (a5)            ; Store a NULL in first byte to create a
  62.  move.w     #50000, d7          ; null string so that heading gets printed
  63.  trap       #9                  ; only once.
  64.  
  65. terminate:
  66.  trap       #8
  67.  
  68. lea_start:
  69.  lea        newline, a2         ; Instruction in the loop.
  70. lea_end:
  71.  
  72. movea_start:
  73.  movea.l     #newline, a2       ; Instruction in the loop.
  74. movea_end:
  75.  
  76.  data
  77. heading:      dc.b       'LEAMOVEA Execution Results',$D,$A,$D,$A,0
  78. header_1:     dc.b       '  Elapsed time for LEA:    ',0
  79. header_2:     dc.b       '  Memory required for LEA:    ',0
  80. header_3:     dc.b $D,$A,'  Elapsed time for MOVEA:  ',0
  81. header_4:     dc.b       '  Memory required for MOVEA:  ',0
  82. newline:      dc.b $D,$A,0
  83.  bss
  84.  align
  85.               ds.l 96
  86. stack:        ds.l  0
  87. program_end:  ds.l  0
  88.  end
  89.  
  90.